package com.example.util;

import com.example.client.ClientData;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

public class iotDao extends BaseDao {

    //环境信息入库
    public void addData(String address, String date, String time, String temp, String humidity, String co2, String lux) {
        String sql = "insert into " + address + "(id,date,time,temperature,humidity,co2,lux) " +
                "values(null,'" + date + "','" + time + "','" + temp + "','" + humidity + "','" + co2 + "','" + lux + "')";

        executeUpdate(sql);
        com.example.server.ServerLog.clientDataList.add(new ClientData(date, time, temp, humidity, co2, lux));
    }

    //查询信息
    public ResultSet searchData(String date, String address) {
        String sql = "select * from " + address + " where date = '" + date + "'";
        return executeSelect(sql);
    }

    //查询端口
    public ResultSet searchData(String address) {
        String sql = "select * from " + address;
        return executeSelect(sql);
    }

}
